<template>
  <div>
    <el-card class="box-card">
      <div class="title11">体育管管理系统</div>
      <div class="title22">
        简介： {{ homeData.introduce }}
      </div>
    </el-card>
    <el-row class="box-card">
      <el-col :span="8">
        <el-card class="cradLeft" shadow="hover">
          <div class="cradItem">
            <div class="cardIcon"><i class="el-icon-user"></i></div>
            <div class="cardText">
              <div class="cardTextItem">会员人数</div>
              <div class="fontWeight">{{ homeData.userCounter }}人</div>
            </div>
          </div>
        </el-card>
        <el-card class="cradLeft" shadow="hover">
          <div class="cradItem">
            <div class="cardIcon"><i class="el-icon-shopping-bag-1"></i></div>
            <div class="cardText">
              <div class="cardTextItem">当天销售额</div>
              <div class="fontWeight">{{ homeData.sale }}元</div>
            </div>
          </div>
        </el-card>
        <el-card class="cradLeft" shadow="hover">
          <div class="cradItem">
            <div class="cardIcon"><i class="el-icon-warning"></i></div>
            <div class="cardText">
              <div class="cardTextItem">商品库存预警</div>
              <div class="fontWeight">{{ homeData.warnCommodity }}项</div>
            </div>
          </div>
        </el-card>
      </el-col>
      <el-col :span="16">
        <el-card class="cardRight">
          <div class="cardRightBox">
            <div class="statusBox">
              <div
                v-for="item in homeData.list"
                :key="item.placeId"
                class="statusBoxItem"
                :style="{backgroundColor: statusColor[item.placeStatus]}"
              >
                <div class="autoM">场地{{ item.placeId }}</div>
              </div>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>
  
  <script>
import api from "../network/home";

export default {
  data() {
    return {
      homeData: [],
      statusColor: ['#FFCDD2 ', '#FFECB3', '#C8E6C9 '],
    };
  },
  computed: {},
  methods: {
    //去到聊天页面
    onSubmit() {
      this.getUser();
    },
    getHomeData() {
      api.getHomeData().then((res) => {
        this.homeData = res.data.data;
      });
    },
    changeFlag(id) {
      const params = {
        userId: id,
      };
      api.changeUserStatus(params).then(() => {
        this.getUser();
      });
    },
    goToDetail(id) {
      const params = {
        userId: id,
      };
      api.changeUserStatus(params).then(() => {
        this.getUser();
      });
    },
  },
  mounted() {
    this.getHomeData();
  },
};
</script>
  
<style lang="scss" scoped>
.title11{
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 20px;
}
.title22{
  font-size: 20px;
  margin-bottom: 20px;
}
.box-card {
  margin: 20px;
}
.cradItem {
  display: flex;
  height: 120px;
  .cardIcon {
    font-size: 50px;
    line-height: 100px;
    color: #409eff;
  }
  .cardText {
    display: flex;
    flex-direction: column;
    height: 100%;
    justify-content: center;
    margin-left: 30px;
    margin-bottom: 50px;
    .cardTextItem {
      margin: 10px;
      margin-bottom: 30px;
      padding: 10px 30px;
    }
    .fontWeight {
      font-weight: 600;
      text-align: center;
      margin-top: -10px;
    }
  }
}
.cradLeft {
  height: 160px;
  margin-bottom: 20px;
}
.cardRight {
  margin-left: 30px;
}
.cardRightBox {
  // display: flex;
  justify-content: space-around;
}
.desBox {
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  width: 200px;
  height: 300px;
  border: 1px solid;
}
.statusBox {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  text-align: center;
  .statusBoxItem {
    display: flex;
    align-items: center;
    justify-content: space-around;
    text-align: center;
    width: 40%;
    border: 1px solid;
    height: 160px;
  }
}
</style>